package Articulo.src.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import net.miginfocom.swing.MigLayout;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;

import Articulo.src.business.managers.ArticleMgr;
import business.entities.Category;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class add extends JFrame {

	private JPanel contentPane;
	private JTextField nombre;
	private JTextField precio;
	private JTextField ingred;
	private JTextField desc;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					add frame = new add();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public add() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new MigLayout("", "[][][][grow]", "[][][][][][][][]"));
		
		JLabel lblNombre = new JLabel("Nombre");
		contentPane.add(lblNombre, "cell 1 1");
		
		nombre = new JTextField();
		contentPane.add(nombre, "cell 3 1,growx");
		nombre.setColumns(10);
		
		JLabel lblPrecio = new JLabel("Precio");
		contentPane.add(lblPrecio, "cell 1 2");
		
		precio = new JTextField();
		contentPane.add(precio, "cell 3 2,growx");
		precio.setColumns(10);
		
		JLabel lblIngredientes = new JLabel("Ingredientes");
		contentPane.add(lblIngredientes, "cell 1 3");
		
		ingred = new JTextField();
		contentPane.add(ingred, "cell 3 3,growx");
		ingred.setColumns(10);
		
		JLabel lblCategoria = new JLabel("Categoria");
		contentPane.add(lblCategoria, "cell 1 4");
		
		JLabel lblDescripcion = new JLabel("Descripcion");
		contentPane.add(lblDescripcion, "cell 1 5");
		
		desc = new JTextField();
		contentPane.add(desc, "cell 3 5,growx");
		desc.setColumns(10);
		
		JButton btnAgregar = new JButton("Agregar");
		btnAgregar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String n= nombre.getText();
				int p = Integer.parseInt(precio.getText());
				//Category c = new Category((String)comboBox.getSelectedItem());
				String ing = ingred.getText();
				String[] ings = ing.split(" " );
				
				//ArticleMgr ar = new ArticleMgr();
				String descrip = desc.getText();
				//confirmAdd conf = new confirmAdd(n,p, (String)comboBox.getSelectedItem(), ing, descrip);
				//conf.setVisible(true);
				//confirmAdd conf = new confirmAdd()
				//String n, int p, String cat, String ing, String desc
			}
		});
		contentPane.add(btnAgregar, "cell 1 7");
	}

}
